<style>
    .w120 {
        width: 120px;
    }
</style>
<link rel="stylesheet" href="__PUBLIC__/yksui/css/multi-select.css" rel="stylesheet"/>
<div class="container-fluid">
    <div class="wrapper">
        <div class="panel" id="nav">
            <div class="panel-heading"><h3 class="panel-title">PC单号查询</h3></div>
            <div class="panel-body">
                <form action="__URL__/pcSearch" method="get" id="form" onsubmit="return check()">
                    <div class="container-fluid">
                        <div class="col-sm-12 col-md-3 add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">PC单号</span>
                                <textarea name="pc_id" class="form-control" rows="3" placeholder="支持多条查询，中间换行或者空格">{$_GET['pc_id']}</textarea>
                                <!--<input name="pc_id" type="text" value="{$_GET['pc_id']}">-->
                            </div>
                        </div>
                        <div class="col-sm-12 col-md-5 add-space">
                            <div class="input-group input-group-md">
                                <span class="input-group-addon">需求创建时间</span>
                                <input class="form-control form-date_1 w120" type="text" name="start_time" value="{$_GET['start_time']}"  readonly>
                                <span class="input-group-addon"><span class="icon-calendar"></span></span>
                                <input class="form-control form-date_1 w120" type="text" name="end_time"  value="{$_GET['end_time']}" readonly>
                                <span class="input-group-addon fix-border fix-padding">&nbsp;<span class="text-danger">0</span>天</span>
                            </div>
                        </div>

                    </div>

                    <div class="col-md-3 add-space">
                        <input class="btn btn-primary" type="submit" value="搜索">
                        <input class="btn btn-warning" type="button" onclick="download()" value="导出">
                        <input class="btn btn-default" type="reset" value="重置">
                    </div>
                </form>
            </div>

            <div class="clearfix"></div>

            <table class="table  " cellspacing="0" width="100%">
                <thead>
                <tr>
                    <th>PC单号</th>
                    <th>总数</th>
                    <th>sku</th>
                    <th>状态</th>
                    <!--<th>平台计划单状态</th>-->
                    <th>shipmentId</th>
                    <th>站点</th>
                    <th>账号</th>
                    <th>Asin</th>
                    <!--<th>虚拟sku</th>-->
                    <th>seller_sku</th>
                    <th>中文名称</th>
                    <th>创建时间</th>

                </tr>
                </thead>
                <tbody>
                <volist name="rec" id="vo" ken="num">
                    <?php
                    $num = count($rec[$key]);
                    foreach($rec[$key] as $v =>$k){
                    ?>

                        <tr>
                            <php>if($v==0){</php>
                            <td rowspan="<?=$num?>" style="vertical-align: middle">{$k.pc_id}</td>
                            <td rowspan="<?=$num?>" style="vertical-align: middle">{$num}</td>
                            <php>}</php>
                            <td>{$k.sku}</td>
                            <td>{$k.end_status}</td>
                            <!--<td>{$k.ship_status}</td>-->
                            <td>{$k.shipmentid}</td>
                            <td>{$k.site_id}</td>
                            <td>{$k.account_name}</td>
                            <td>{$k.asin}</td>
                            <!--<td>{$k.sku_virtual}</td>-->
                            <td>{$k.seller_sku}</td>
                            <td>{$k.sku_name}</td>
                            <td>{$k.create_time}</td>

                        </tr>
                    <?php }?>
                </volist>
                </tbody>
            </table>
            <div class="clearfix clear"></div>

            <div class="col-md-6 pull-left" style="margin-top: 10px;">

                <label>每页 {$size} 条记录，共 {$count}条</label>
            </div>
            <div class="col-md-6" style="margin-top: 10px;">
                <div class="page pull-right" style="padding: 0;margin: 0">
                    {$page}
                </div>
            </div>

        </div>
    </div>
</div>
</div>

<!--解绑-->

<script type="text/javascript" src="__PUBLIC__/yksui/js/jquery.multi-select.js"></script>
<script type="text/javascript" src="__PUBLIC__/javascripts/admin/layer/layer.js"></script>
<script type="text/javascript">
    $('.form-date_1').datetimepicker({
        lang:'ch',
        timepicker:true,
        format:'Y-m-d H:i:s',
        formatDate:'Y-m-d H:i:s',
        onChangeDateTime:function(dp,$input){
            //alert(dp);
            date_needs();
        },
        onSelectDate:function()
        {
            date_needs();
        }
    });
    var date_needs =function(){
        var start_time = Date.parse($("input[name=start_time]").val());
        var end_time   = Date.parse($("input[name=end_time]").val());
        var diff       = end_time-start_time;                         //时间差的毫秒数
        var days=Math.floor(diff/(24*3600*1000));
        if(!isNaN(days))
            $(".text-danger").html(days);
    };
    function check() {
        var start_time = $("input[name=start_time]").val();
        var end_time   = $("input[name=end_time]").val();
        var pc_id = $("textarea[name=pc_id]").val();
        var diff       = Date.parse(end_time)-Date.parse(start_time);                         //时间差的毫秒数
        var days=Math.floor(diff/(24*3600*1000));
//        alert(pc_id);return false;
        if(pc_id=='' && start_time=='' && end_time==''){
            layer.msg('请输入查询条件',{icon:5});
            return false;
        }
        if(diff<0){
            layer.msg('请选择正确时间',{icon:5});
            return false;
        }
    }
    function download() {
        var start_time = $("input[name=start_time]").val();
        var end_time   = $("input[name=end_time]").val();
        var pc_id = $("textarea[name=pc_id]").val();
        var diff       = Date.parse(end_time)-Date.parse(start_time);                         //时间差的毫秒数
        var days=Math.floor(diff/(24*3600*1000));
        var data = $('#form').serialize();
        if(pc_id=='' && start_time=='' && end_time==''){
            layer.msg('请输入查询条件',{icon:5});
            return false;
        }
        if(diff<0){
            layer.msg('请选择正确时间',{icon:5});
            return false;
        }  else{
            window.location.href = '__URL__/pcSearch?down=ok&'+data;
        }
    }
</script>